package com.itheima.reggie_auto.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.itheima.reggie_auto.entity.OrderDetail;
import com.itheima.reggie_auto.mapper.OrderDetailMapper;
import com.itheima.reggie_auto.service.OrderDetailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class OrderDetailServiceImpl implements OrderDetailService {

    @Autowired
    private OrderDetailMapper orderDetailMapper;

    public void saveBatch(List<OrderDetail> list){
        for (OrderDetail orderDetail : list) {
            orderDetailMapper.insert(orderDetail);
        }
    }

    @Override
    public List<OrderDetail> getByOrderId(Long id) {
        LambdaQueryWrapper<OrderDetail> lqw = new LambdaQueryWrapper<>();
        lqw.eq(OrderDetail::getOrderId,id);
        return orderDetailMapper.selectList(lqw);
    }
}
